import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '商品名称',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '商品分类',
    align:"center",
    dataIndex: 'goodTypeId_dictText'
   },
   {
    title: '库存',
    align:"center",
    dataIndex: 'stockNum'
   },
   {
    title: '状态（0下架，1上架）',
    align:"center",
    dataIndex: 'status'
   },
   {
    title: '商品图片',
    align:"center",
    dataIndex: 'goodUrl',
    customRender:render.renderImage,
   },
   {
    title: '排序',
    align:"center",
    dataIndex: 'isort'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "商品名称",
      field: "name",
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "商品分类",
      field: "goodTypeId",
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"good_type,name,id"
      },
      colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '商品名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入商品名称!'},
          ];
     },
  },
  {
    label: '商品分类',
    field: 'goodTypeId',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"good_type,name,id"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入商品分类!'},
          ];
     },
  },
  {
    label: '库存',
    field: 'stockNum',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入库存!'},
          ];
     },
  },
  {
    label: '商品图片',
    field: 'goodUrl',
     component: 'JImageUpload',
     componentProps:{
      },
  },
  {
    label: '商品描述',
    field: 'contentText',
    component: 'JEditor',
  },
  {
    label: '排序',
    field: 'isort',
    component: 'InputNumber',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
//子表表格配置
export const goodDetailColumns: JVxeColumn[] = [
    {
      title: '市场价格',
      key: 'marketPrice',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '商品价格',
      key: 'price',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
    {
      title: '库存',
      key: 'stockNum',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
    {
      title: '期限',
      key: 'termId',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
  ]
